package cn.yanjr.mall.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Map;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.yanjr.common.utils.DateUtil;
import cn.yanjr.common.web.BaseServlet;
import cn.yanjr.wechat.util.CommonUtil;

@WebServlet("/send/msg")
public class SendMessageServlet extends BaseServlet{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1123111769158574898L;

	public void sentTask(HttpServletRequest request, HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/json; charset=utf-8");
		
		PrintWriter out;
		try {
			Map<String, String[]> requestMap =  request.getParameterMap();
			String openId = requestMap.get("openId")[0];
			String taskId = requestMap.get("taskId")[0];
			String taskGroup = requestMap.get("taskGroup")[0];
			String createTime = requestMap.get("createTime")[0];
			String type = requestMap.get("type")[0];
			createTime = DateUtil.formatDateTime(new Date(new Long(createTime)));
			CommonUtil.sendTaskTempMsg(openId, taskId, taskGroup, createTime, type);
			
			
			out = response.getWriter();
			out.println(JSON.toJSONString(""));
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

}
